package com.bosssoft.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.bosssoft.entity.dto.FibAuthDTO;
import com.bosssoft.enums.CopyPropertityEnum;
import com.bosssoft.exception.DaoException;
import com.bosssoft.factory.PageFactory;
import com.bosssoft.page.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bosssoft.entity.po.FibAuthPO;
import com.bosssoft.mapper.FibAuthMapper;
import com.bosssoft.service.FibAuthService;
/**
 * @author Li kexi
 * Created on 2021/8/16.14:32
 */
@Slf4j
@Service
public class FibAuthServiceImpl extends ServiceImpl<FibAuthMapper, FibAuthPO> implements FibAuthService{
    @Override
    public boolean addAuth(FibAuthDTO authDTO) {
        try {
            FibAuthPO authPO = new FibAuthPO();
            BeanUtils.copyProperties(authDTO, authPO);
            return this.baseMapper.insert(authPO) > 0;
        } catch (Exception e) {
            log.info("addAuth发生异常");
            throw DaoException.error().setCodeAndMessage(CopyPropertityEnum.RESOURCE_NULL_ERROR);
        }
    }

    @Override
    public boolean modifyAuth(FibAuthDTO authDTO) {
        try {
            FibAuthPO authPO = new FibAuthPO();
            BeanUtils.copyProperties(authDTO, authPO);
            return this.baseMapper.updateById(authPO) > 0;
        } catch (Exception e) {
            throw DaoException.error().setCodeAndMessage(CopyPropertityEnum.RESOURCE_NULL_ERROR);
        }
    }

    @Override
    public boolean banAuthById(Long authId, Integer status) {
        return this.baseMapper.banAuthById(authId, status) > 0;
    }

    @Override
    public boolean deleteAuth(Long authId) {
        return this.baseMapper.deleteById(authId) > 0;
    }

    @Override
    public String getUrlById(Long id) {
        return this.baseMapper.getUrlById(id);
    }

    @Override
    public int updateBatch(List<FibAuthPO> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<FibAuthPO> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<FibAuthPO> list) {
        return baseMapper.batchInsert(list);
    }
    @Override
    public int insertOrUpdate(FibAuthPO record) {
        return baseMapper.insertOrUpdate(record);
    }
    @Override
    public int insertOrUpdateSelective(FibAuthPO record) {
        return baseMapper.insertOrUpdateSelective(record);
    }
}
